<?
	  	  include("/inc/header.html") {}
    ?>
<div class="col-lg-4">
	<div class="panel" style="height: 280px; overflow: auto;">
		<div class="panel-body">
		   <!--  &nbsp; &nbsp; &nbsp;<div><a href="javascript:qingling();">根目录</a></div> -->
		    <div style="margin-top: -10px;margin-left: 10px;">
			<button style="height: 35px;width: 55px;" type="button" class="btn btn-blue btn-xs" onclick="qingling()"><h5>根目录</h5></button></div>
			<ul id="tree" class="ztree" style="width:300px"; overflow:auto;"></ul>
		</div>	
	</div>
</div>

<script>

  var classid;
  var classname;
	$(function() {
		initTree();
	});
	function initTree() {
		$.ajax({
			type : "post",
			data : {},
			url : "knowledgeEditDataQueryDepartment.do",
			dataType : "json",
			beforeSend : function(XMLHttpRequest) {
			},
			success : drawTree,
		});
	}

	function drawTree(data) {
		var setting = {
			view : {
				dblClickExpand : false,
			},
			data : {
				simpleData : {
					enable : true,
				}
			},
			check : {
				enable : false
			},
			callback : {
				onClick : onClick
			},
		};
		var zNodes = eval(data);
		$.fn.zTree.init($("#tree"), setting, zNodes).expandAll(true);
		zTree = $.fn.zTree.getZTreeObj("tree");
		zTree.expandNode(zTree.getNodes()[0], true);

	}
	
	function onClick(e, treeId, treeNode) {
		classid = treeNode.id;		
		classname=treeNode.name;  
	}
	
		function  save(){
		if(classid==null){
		var index = parent.layer.getFrameIndex(window.name); 
		parent.$("#parentClassid").val("0");
	    parent.$("#parentclassname").val("根节点");
		 parent.layer.close(index);
		}else{
		var index = parent.layer.getFrameIndex(window.name); 
	    parent.$("#parentClassid").val(classid);
	    parent.$("#parentclassname").val(classname);
	    parent.layer.close(index);
	    }
     }
	
	function qingling(){
	var index = parent.layer.getFrameIndex(window.name); 
		parent.$("#parentClassid").val("0");
	    parent.$("#parentclassname").val("根节点");
		 parent.layer.close(index);
	}
	
	
</script>